package com.hik.controller;

import com.alibaba.fastjson.JSONObject;
import com.hik.entity.*;
import com.hik.utils.HikHcUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@Api(tags = "会议控制")
@RestController
@RequestMapping("hik")
public class HikController {
    @ApiOperation("邀请会场")
    @PutMapping("yqhc")
    public JSONObject yqHC(@ApiParam("会议 indexCode")@RequestParam("indexCode")String indexCode,
                           @ApiParam("会场 indexCode 数组")@RequestParam("terminalIndexCodes")String terminalIndexCodes[]){
        MeetingHc meetingHc=new MeetingHc(terminalIndexCodes);
        String str=JSONObject.toJSONString(meetingHc);
        JSONObject jsonObject =HikHcUtils.hyKzHCYQ(indexCode,str);
        return jsonObject;
    }
    @ApiOperation("剔除会场")
    @PutMapping("tchc")
    public JSONObject tcHC(@ApiParam("会议 indexCode")@RequestParam("indexCode")String indexCode,
                           @ApiParam("会场 indexCode 数组")@RequestParam("terminalIndexCodes")String terminalIndexCodes[]){
        MeetingHc meetingHc=new MeetingHc(terminalIndexCodes);
        String str=JSONObject.toJSONString(meetingHc);
        JSONObject jsonObject =HikHcUtils.hyKZHCTC(indexCode,str);
        return jsonObject;
    }
    @ApiOperation("开启会议")
    @PostMapping("hystart")
    public JSONObject hystart(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode){
        JSONObject jsonObject =HikHcUtils.hyStart(indexCode);
        return jsonObject;
    }
    @ApiOperation("关闭会议")
    @PostMapping("hyEnd")
    public JSONObject hyEnd(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode){
        JSONObject jsonObject =HikHcUtils.hyEnd(indexCode);
        return jsonObject;
    }
    @ApiOperation("会议视频 URL")
    @PostMapping("hyUrl")
    public JSONObject hyUrl(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode){
        JSONObject jsonObject =HikHcUtils.hyGetUrl(indexCode);
        return jsonObject;
    }
    @ApiOperation("画面设置")
    @PostMapping("hyHmsz")
    public JSONObject hyHmsz(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode,
                             @ApiParam("画面设置实体类")@RequestBody HMSZ hmsz){
        String str=JSONObject.toJSONString(hmsz);
        JSONObject jsonObject =HikHcUtils.hyHmsz(indexCode,str);
        return jsonObject;
    }
    @ApiOperation("会议延长")
    @PostMapping("hyYc")
    public JSONObject hyYc(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode,
                             @ApiParam("延长会议时间，单位分钟，范围 10~120")@RequestParam("prolongTime")long prolongTime){
        HashMap<String,Long> map=new HashMap<>();
        map.put("prolongTime",prolongTime);
        String str=JSONObject.toJSONString(map);
        JSONObject jsonObject =HikHcUtils.hyYc(indexCode,str);
        return jsonObject;
    }
    @ApiOperation("开关麦克风")
    @PostMapping("hyMcf")
    public JSONObject hyMcf(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode,
                           @ApiParam("麦克风打开关闭，false-打开，true-关闭")@RequestParam("audioInputDisabled")boolean audioInputDisabled,
                            @ApiParam("会场 indexCode 数组")@RequestParam("terminalIndexCodes")String terminalIndexCodes[]
    ){
        HashMap<String,Object> map=new HashMap<>();
        map.put("audioInputDisabled",audioInputDisabled);
        map.put("terminalIndexCodes",terminalIndexCodes);
        String str=JSONObject.toJSONString(map);
        JSONObject jsonObject =HikHcUtils.hyMkf(indexCode,str);
        return jsonObject;
    }
    @ApiOperation("开关扬声器")
    @PostMapping("hyYsq")
    public JSONObject hyYsq(@ApiParam("会议的indexCode")@RequestParam("indexCode") String indexCode,
                            @ApiParam("扬声器打开关闭，false-打开，true-关闭")@RequestParam("mute")boolean mute,
                            @ApiParam("会场 indexCode 数组")@RequestParam("terminalIndexCodes")String terminalIndexCodes[]
    ){
        HashMap<String,Object> map=new HashMap<>();
        map.put("mute",mute);
        map.put("terminalIndexCodes",terminalIndexCodes);
        String str=JSONObject.toJSONString(map);
        JSONObject jsonObject =HikHcUtils.hyYsq(indexCode,str);
        return jsonObject;
    }
}
